package com.cqw.auth.config.handler;

import com.cqw.auth.enums.CodeEnum;
import com.cqw.auth.utils.ResultJSON;
import com.cqw.auth.utils.SecurityHandlerUtil;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 认证失败
 * @Author cqw
 * @Date 2020年12月31日15:08:26
 */
public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
        SecurityHandlerUtil.responseHandler(httpServletResponse,new ResultJSON(CodeEnum.USER_NOT_LOGIN_FAILURE));
    }
}
